<template>
	<view class="padding">
		<u-navbar title="订单奖励" :autoBack="true" :placeholder="true" leftIconColor="#000000" :titleStyle="{color: '#000000'}" bgColor="#ffffff">
		</u-navbar>
		<view class="padding bg-white radius-5 margin-bottom font-13" v-for="(item, index) in orderAwardList" :key="index">
			<view class="flex justify-between border-bottom padding-bottom-sm">
				<view class="padding-top-xs text-black9">下单时间：{{item.createTime}}</view>
				<view class="padding-top-xs text-theme">
					<text :class="[item.sendFlag == 1 ? 'text-black' : 'text-black9']" v-for="(sItem, sIndex) in sendFlagStatus" :key="sIndex" v-if="item.sendFlag == sItem.value">{{sItem.label}}</text>
				</view>
			</view>
			<view class="margin-top-sm">您获得积分：<text class="text-theme">{{item.awardAmount}}</text></view>
			<view class="margin-top-sm">订单金额：{{item.orderAmount}}</view>
			<view class="margin-top-sm">订单编号：{{item.orderId}}<text class="copy-btn" @click="copyCode(item.orderId)">复制</text></view>
			<view class="margin-top-sm">积分说明：{{item.awardName}}</view>
			<!-- <view class="margin-top-sm" v-if="item.releaseType == 2">
				明细：<text class="text-decoration text-black3" @click="toReleaseRecord(item)">查看明细</text>
			</view> -->
		</view>
		<u-loadmore :status="status" />
	</view>
</template>

<script>
	import {
		orderAward
	} from '@/common/api/order.js'
	import {
		walletTypeList
	} from '@/common/api/dict.js'
	export default {
		data() {
			return {
				pageNo: 0,
				orderAwardList: [],
				walletTypeList: walletTypeList,
				status: 'loading',
				sendFlagStatus: [{
					label: '待到账',
					value: 0
				},{
					label: '已到账',
					value: 1
				},{
					label: '发放中',
					value: 2
				},{
					label: '发放异常',
					value: 3
				}]
			};
		},
		onLoad(options) {
			this.getOrderAward()
		},
		onReachBottom() {
			this.getOrderAward()
		},
		methods: {
			copyCode(code) {
				let that = this
				uni.setClipboardData({
					data: code,
					success: function() {
						that.$msg('复制成功')
					}
				})
			},
			toReleaseRecord(item) {
				uni.navigateTo({
					url: '/pages/order/releaseRecord?logId=' + item.logId
				})
			},
			getOrderAward(walletType) {
				this.pageNo++
				this.status = 'loading'
				orderAward({pageNo: this.pageNo, pageSize: 10}).then(res => {
					this.orderAwardList = this.orderAwardList.concat(res.data)
					if (res.data.length < 10) {
						this.status = 'nomore'
					}
				})
			}
		}
	}
</script>

<style lang="scss">
page {
	background: #f2f2f2;
}
</style>
<style lang="scss" scoped>
.copy-btn {
	border: 2rpx solid #808080;
	color: #808080;
	font-size: 20rpx;
	padding: 2rpx 10rpx;
	margin-left: 20rpx;
	border-radius: 6rpx;
}
</style>
